package com.crealth.model;

import java.io.Serializable;
import java.sql.Timestamp;

import com.alibaba.fastjson.JSONObject;
import com.crealth.utils.Utils;

public class EventRemindModel implements Serializable {
	private static final long serialVersionUID = 2120412L;
	
	private int id;
	private int userID;
	private String name;
	private String phoneNum;
	private int consumerID;
	private Timestamp remindTm;
	private String remindContext;
	
	public EventRemindModel() {
		name = "";
		phoneNum = "";
		consumerID = 0;
		remindTm = null;
		remindContext = "";
	}	
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}	
	public int getUserID() {
		return userID;
	}
	public void setUserID(int userID) {
		this.userID = userID;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getPhoneNum() {
		return phoneNum;
	}
	public void setPhoneNum(String phoneNum) {
		this.phoneNum = phoneNum;
	}
	public int getConsumerID() {
		return consumerID;
	}
	public void setConsumerID(int consumerID) {
		this.consumerID = consumerID;
	}
	public Timestamp getRemindTm() {
		return remindTm;
	}
	public void setRemindTm(Timestamp remindTm) {
		this.remindTm = remindTm;
	}
	public String getRemindContext() {
		return remindContext;
	}
	public void setRemindContext(String remindContext) {
		this.remindContext = remindContext;
	}
	
	public void parseFromJson(JSONObject dataJson) {
		this.id = Utils.getJsonIntValue(dataJson, "eventID", 0);
		this.name = Utils.getJsonString(dataJson, "name");
		this.phoneNum = Utils.getJsonString(dataJson, "phoneNum");
		this.consumerID = Utils.getJsonIntValue(dataJson, "consumerID", 0);
		long remindTm = dataJson.getLongValue("remindTm");
		this.remindTm = new Timestamp(remindTm * 1000);
		this.remindContext = Utils.getJsonString(dataJson, "remindContext");
	}
	
	public JSONObject toJSONObject() {
		JSONObject jsonObj = new JSONObject();
		jsonObj.put("id", id);
		jsonObj.put("userID", userID);
		jsonObj.put("name", name);
		jsonObj.put("phoneNum", phoneNum);
		jsonObj.put("consumerID", consumerID);
		jsonObj.put("remindTm", remindTm.getTime() / 1000);
		jsonObj.put("remindContext", remindContext);		
		
		return jsonObj;
	}

}
